//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.study.controller;

import com.study.common.ResultJson;
import com.study.pojo.BookPoint;
import com.study.pojo.User;
import com.study.service.BookPointService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/bookPoint")
public class BookPointController {
    @Resource
    private BookPointService bookPointService;

    public BookPointController() {
    }

    @RequestMapping({"/insertBookPoint"})
    @ResponseBody
    public ResultJson insertBookPoint(HttpServletRequest request, String value, Integer bookId) {
        User currentUser = (User)request.getSession().getAttribute("user");
        if (currentUser != null) {
            this.bookPointService.insertOrUpdate(new BookPoint(currentUser.getId(), bookId, value));
            return ResultJson.ok();
        } else {
            return ResultJson.error();
        }
    }
}
